package service;

import util.MySpring;
import dao.AtmDao;
import entity.Atm;

public class AtmService {
    private AtmDao atmDao = MySpring.getBean("dao.AtmDao");

    public String login(String name ,String password){
        Atm atm = atmDao.selectOne(name);
        if (atm != null  && atm.getPassword().equals(password)) {
            return "成功";
        }
        return "用户名或密码错误";
    }

    public Float inquiry(String name){
        return atmDao.selectOne(name).getBalance();
    }

    public void deposit(String name,Float depositBalance){
        Atm atm = atmDao.selectOne(name);
        atm.setBalance(   atm.getBalance()+depositBalance);
        atmDao.update(atm);
    }

    public void insert(Atm atm) {
        System.out.println("AtmService.insert");
    }
}
